<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="__PUBLIC__/echarts/echarts.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<style>

    .layui-table th, .layui-table td{
        padding: 9px 6px;
        text-align: center;
    }
    .operation-menu a{
        margin: 5px 0;!important;
    }
    .layui-form-item{
        margin-bottom:0px;
    }
    .layui-input-block{
        margin-left: 0px;
        min-height: 0px;
    }
    /*.layui-form select{*/
    /*display: inline-block;*/
    /*}*/
</style>
<body>
<div class="layui-fluid main">
    <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
        <div class="layui-form-item" style="float: left;">
            <form id="form1" class="layui-form serch" action="{:url('admin/goods/othergoods')}" method="post">
                <div class="layui-form-item" style="float: left;">
                    <div class="layui-input-inline">
                        <input type="text" name="keywords" lay-verify="title" autocomplete="off" placeholder="商品ID / 中英名称 / viatorCode" value="{if isset($where['keywords'])}{$where['keywords']}{/if}" class="layui-input layui-btn-sm">
                    </div>
                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="city_id" lay-search="">
                                <option value="">城市</option>
                                {volist name='city' id='vo'}
                                <option value="{$vo.id}" {if  isset($where['city_id']) AND $vo.id==$where['city_id'] } selected{/if}>{$vo.name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="classify_id" lay-search="">
                                <option value="">商品分类</option>
                                {volist name='classify' id='vo'}
                                <option value="{$vo.classify_id}" {if  isset($where['classify_id']) AND $vo.classify_id==$where['classify_id']} selected{/if}>{$vo.classify_name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>

                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="goods_status" lay-search="">
                                <option value="">商品状态</option>
                                <option value="1" {if  isset($where['goods_status']) AND $where['goods_status']=='1'} selected{/if}>售卖中</option>
                                <option value="2" {if  isset($where['goods_status']) AND $where['goods_status']=='2'} selected{/if}>未售买</option>
                                <option value="3" {if  isset($where['goods_status']) AND $where['goods_status']=='3'} selected{/if}>已售罄</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="team_id" lay-search="">
                                <option value="" >商品来源</option>
                                {volist name='goodssoure' id='vo'}
                                <option value="{$vo.id}" {if  isset($where['team_id']) AND $vo.id==$where['team_id']} selected{/if}>{$vo.name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="isquestion" lay-search="">
                                <option value="">预约问题</option>
                                <option value="1" {if  isset($where['isquestion']) AND $where['isquestion']=='1'} selected{/if}>不存在</option>
                                <option value="2" {if  isset($where['isquestion']) AND $where['isquestion']=='2'} selected{/if}>存在</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="isupdated" lay-search="">
                                <option value="">更新状态</option>
                                <option value="1" {if  isset($where['isupdated']) AND $where['isupdated']=='1'} selected{/if}>需要更新</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="accidentDrop" lay-search="">
                                <option value="">意外下架</option>
                                <option value="1" {if  isset($where['accidentDrop']) AND $where['accidentDrop']=='1'} selected{/if}>已下架</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="api_type" lay-search="">
                                <option value="">Api接口类型</option>
                                <option value="0" {if  isset($where['api_type']) AND $where['api_type']=='0'} selected{/if}>英文接口</option>
                                <option value="1" {if  isset($where['api_type']) AND $where['api_type']=='1'} selected{/if}>中文接口</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="confirm_type" lay-search="">
                                <option value="">确认类型</option>
                                <option value="1" {if  isset($confirm_type) AND $confirm_type=='1'} selected{/if}>立即出票</option>
                                <option value="2" {if  isset($confirm_type) AND $confirm_type=='2'} selected{/if}>确认后出票</option>
                                <option value="3" {if  isset($confirm_type) AND $confirm_type=='3'} selected{/if}>不可用二次确认</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="orderType" lay-search="">
                                <option value="" >订单类型</option>
                                {volist name='orderType' id='vo'}
                                <option value="{$vo.type}" {if  isset($where['orderType']) AND $vo.type==$where['orderType']} selected{/if}>{$vo.name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="isTob" lay-search="">
                                <option value="" >Tob上架状态</option>
                                <option value="1" {if isset($where['isTob']) && $where['isTob']==1}selected{/if}>已上架</option>
                                <option value="2" {if isset($where['isTob']) && $where['isTob']==2}selected{/if}>未上架</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <button class="layui-btn layui-btn-danger layui-btn-sm" lay-submit="" lay-filter="serch">搜索</button>
                            <button type="reset" class="layui-btn layui-btn-danger layui-btn-sm clear_form">重置</button>
                        </div>
                    </div>
                    <div class="layui-input-inline">
                        <div class="layui-inline" style="width: 250px;">
                            <a href="{:url('admin/goods/othergoods')}?exportFlag=1" class="layui-btn layui-btn-default layui-btn-sm">导出Excel</a>
                            <a href="{:url('admin/goods/batchViatorImagesByCodes')}" class="layui-btn layui-btn-normal layui-btn-sm batchViatorImages">批量拉取viator产品图片</a>
                        </div>
                    </div>

                </div>
            </form>
        </div>
    </fieldset>
    <table class="layui-table" lay-even="" lay-skin="line">
        <colgroup>
            <col width="5%">
            <col width="5%">
            <col width="5%">
            <col width="5%">
            <col width="30%">
            <col width="5%">
            <col width="5%">
            <col width="5%">
            <col width="5%">
            <col width="5%">
            <col width="5%">
            <col width="5%">
            <col width="5%">
            <!--<col width="8%">-->
            <!--<col width="6%">-->
            <col width="5%">
            <col width="5%">
            <col width="7%">
            <col width="5%">
        </colgroup>
        <thead>
        <tr>
            <th>商品ID</th>
            <th>viatorCode</th>
            <th>略缩图</th>
            <th>产品Code</th>
            <th>商品名称</th>
            <th>常见问题</th>
            <th>上传附件</th>
            <th>商品类型</th>
            <th>城市</th>
            <th>售卖价</th>
            <th>采购价</th>
            <th>商品状态</th>
            <th>关于问题</th>
            <th>预约类型</th>
            <!--<th>开始时间</th>-->
            <!--<th>结束时间</th>-->
            <th>tob状态</th>
            <th>直订/热门</th>
            <th>查询价格</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name='liebiao' id='v'}
        <tr>
            <td>{$v.goods_id}</td>
            <td>{$v.code}</td>
            <td style="text-align: center;">
                <?php
                    if(!empty($v['goods_image'])){
                    $img=explode(',',$v['goods_image'] );
                    if(empty($img[1])){
                 ?>
                <img src="{$v['goods_image']}" width="64px">
                <?php  }
                    else{
                ?>
                <img src="{$img[1]}" width="64px">
                <?php  }
                    }else{
                }?>
            </td>
            <td>{$v.goods_tcode}</td>

            <td>
                <div title="{$v.goods_name}">{$v.goods_name}</div>
            </td>
            <td>
                {if $v.faq_flag>0}
                &nbsp;<a href="{:url('admin/faq/showFaq',['groupid'=>$v.goods_id,'typeid'=>3])}" class="layui-btn layui-btn-xs layui-btn-warm" target="_blank"  style="margin-right: 0;font-size:12px;">FAQ</a>
                {else}
                &nbsp;<a href="{:url('admin/faq/showFaq',['groupid'=>$v.goods_id,'typeid'=>3])}" class="layui-btn layui-btn-xs layui-btn-primary" target="_blank"  style="margin-right: 0;font-size:12px;">暂无</a>
                {/if}
            </td>
            <td>
                {if !empty($v.up_url)}
                &nbsp;<a href="{:url('admin/goods/savefile',['id'=>$v.goods_id,'typeid'=>1])}" class="layui-btn layui-btn-xs layui-btn-warm a_menu" target="_blank"  style="margin-right: 0;font-size:12px;">附件</a>
                {else}
                &nbsp;<a href="{:url('admin/goods/savefile',['id'=>$v.goods_id,'typeid'=>1])}" class="layui-btn layui-btn-xs layui-btn-primary a_menu" target="_blank"  style="margin-right: 0;font-size:12px;">暂无</a>
                {/if}
            </td>
            <td>
                {$v.tag_name}
            </td>
            <td>
                {$v.name}
            </td>
            <td>{$v.price}</td>
            <td>{$v.merchantNetPrice}</td>
            <td>
                {switch name="v.goods_status"}
                {case value=""}未知{/case}
                {case value="1"}售卖中{/case}
                {case value="2"}未售卖{/case}
                {case value="3"}已告罄{/case}
                {default /}default
                {/switch}
            </td>
            <td>
                {if $v.isquestion==1}不存在{else}存在问题{/if}
            </td>
            <td>
                {if $v.confirm_type==1}立即出票{elseif $v.confirm_type==2}确认后出票{else}不可用二次确认{/if}
            </td>
            <!--<td>{$v.starttime|date='Y-m-d',###} </td>-->
            <!--<td>{$v.endtime|date='Y-m-d',###}</td>-->
            <td>
                {if !empty($v.show_toB) && $v.show_toB==1}
                <span style="color:green">已上架</span>
                {else}
                <span style="color:red">未上架</span>
                {/if}
            </td>
            <td>
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="checkbox" name="popular" value="1" id="{$v.goods_id}" lay-filter="popular" lay-skin="switch" <?php if($v['popular']==1){ echo 'checked';} ?> lay-text="热门|普通">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="checkbox" name="recommend" value="1" id="{$v.goods_id}" lay-filter="recommend" lay-skin="switch" <?php if($v['recommend']==1){ echo 'checked';} ?> lay-text="直订|非直">
                        </div>
                    </div>
                </form>
            </td>

            <td>
                <a href="{:url('admin/goods/showprice')}?id={$v.goods_id}" data="{$v.goods_name}" class="layui-btn layui-btn-xs layui-btn-warm showprice"  style="margin-right: 0;font-size:12px;background: darkslategrey">查看</a>
            </td>
            <td class="operation-menu">
                <a href="{:url('admin/goods/addgoodsother')}?id={$v.goods_id}" class="layui-btn layui-btn-xs layui-btn-warm a_menu"  style="margin-right: 0;font-size:12px;background: darkslategrey">编辑</a>
                {if $v.isupdated==1}<a href="{:url('admin/goods/changDetailT')}?code={$v.code}" class="layui-btn layui-btn-xs layui-btn-warm a_menu"  style="margin-right: 0;font-size:12px;background: #51a954">更新</a>{/if}
                {if $v.accidentDrop==1}<a href="{:url('admin/goods/clearDropFlag')}?code={$v.code}" class="layui-btn layui-btn-xs layui-btn-danger changeFlag"  style="margin-right: 0;font-size:12px;background: #5bb5a4">已阅</a>{/if}
                {switch name="v.goods_status"}
                {case value=""}  {/case}
                {case value="1"} <a href="####" class="layui-btn layui-btn-xs layui-btn-danger shelves" data-id="{$v.goods_status}"  codeid="{$v.goods_id}" style="margin-right: 0;font-size:12px;">下架</a>{/case}
                {case value="2"} <a href="####" class="layui-btn layui-btn-xs layui-btn-danger shelves" data-id="{$v.goods_status}" codetype="{$v.orderType}" codeid="{$v.goods_id}" style="margin-right: 0;font-size:12px;">上架</a>{/case}
                {case value="3"} <a href="####" class="layui-btn layui-btn-xs layui-btn-danger " data-id="{$v.goods_status}" codeid="{$v.goods_id}" style="margin-right: 0;font-size:12px;background: #777777">已售完</a>{/case}
                {default /}default
                {/switch}
                <a href="{:url('admin/goods/othergoodsnotice')}?id={$v.goods_id}" class="layui-btn layui-btn-xs layui-btn-normal notice"  style="margin-right: 0;font-size:12px;">提醒配置</a>

            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div>{$liebiao->render1()}</div>

    <script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>
    <script>
        layui.use('form', function () {
            var form = layui.form;
            form.on('switch(recommend)', function(data){
                var id= $(this).attr('id')
                var    recommend;
                if(data.elem.checked){
                    recommend =1;
                }else{
                    recommend =0;
                }
                $.ajax({
                    url:"{:url('admin/goods/recommend')}",
                    data:{'id':id,'recommend':recommend},
                    type:'post',
                    async: false,
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code == 1) {
                            setTimeout(function(){
                                location.reload();
                            },1500)
                        }
                    }
                })
            });

            form.on('switch(popular)', function(data){
                var id= $(this).attr('id')
                var popular;
                if(data.elem.checked){
                    popular =1;
                }else{
                    popular =0;
                }
                $.ajax({
                    url:"{:url('admin/goods/recommend')}",
                    data:{'id':id,'popular':popular},
                    type:'post',
                    async: false,
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code == 1) {
                            setTimeout(function(){
                                location.reload();
                            },1500);
                        }
                    }
                })
            });
        });
    </script>
    <script>
        var message;
        layui.config({
            base: '__JS__/',
            version: '1.0.1'
        }).use(['app', 'message'], function() {
            var app = layui.app,
                $ = layui.jquery,
                layer = layui.layer;
            //将message设置为全局以便子页面调用
            message = layui.message;
            //主入口
            app.set({
                type: 'iframe'
            }).init();
        });
    </script>
    <script type="text/javascript">
        $('.delete').click(function(){
            var id = $(this).attr('codeid');
            layer.confirm('确定要删除?', function(index) {
                $.ajax({
                    url:"{:url('admin/coupon/delcoupon')}",
                    data:{id:id},
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code == 1) {
                            setTimeout(function(){
                                location.reload();
                            },1500)
                        }
                    }
                })
            })
        });
        $('.shelves').click(function(){
            var id = $(this).attr('codeid');
            var goods_status= $(this).attr('data-id');
            var uptext='是否确认操作？';
            //上架数据判断
            if(goods_status=='2'){
                var orderType= $(this).attr('codetype');
                var arr = [ "Vehicle","Custom","Other","Price_Gap","Self_Drive","Personal_Tailor","Subscription" ];
                var type_msg = '';
                if($.inArray(orderType,arr) < 0){
                    type_msg = "该类型商品订单可自动建单，是否确认上架？";
                }else{
                    type_msg = "该类型商品订单需手动建单，是否确认上架？";
                }
                $.ajax({
                    url:"{:url('admin/goods/addprice')}",
                    async:false,
                    data:{id:id},
                    success:function(res) {
                        if(res.code=='001'){
                            uptext='亲，供应商好像下架了商品诶！是否确认上架？'
                        }else if(res.code=='002'){
                            uptext='亲，该商品未来6个月内没有可预约的行程，是否确认上架？'
                        }else if(res.code=='003'){
                            uptext=type_msg
                        }
                    }
                });
                layer.confirm(uptext, function(index) {
                    $.ajax({
                        url:"{:url('admin/goods/shelves')}",
                        data:{id:id,goods_status:goods_status},
                        success:function(res) {
                            layer.msg(res.msg);
                            if(res.code == 1) {
                                setTimeout(function(){
                                    location.reload();
                                },1500);
                            }
                        }
                    })
                })
            }else{
                layer.confirm(uptext, function(index) {
                    $.ajax({
                        url:"{:url('admin/goods/shelves')}",
                        data:{id:id,goods_status:goods_status},
                        success:function(res) {
                            layer.msg(res.msg);
                            if(res.code == 1) {
                                setTimeout(function(){
                                    location.reload();
                                },1500);
                            }
                        }
                    })
                })
            }
        })
    </script>
    <script type="text/javascript">
        layui.use('layer', function(){
            var layer = layui.layer;
            $('.a_menu').click(function(){
                var url = $(this).attr('href');
                var a = 0;
                $.ajax({
                    url:url
                    ,async:false
                    ,success:function(res){
                        if(res.code == 0) {
                            layer.msg(res.msg);
                            a = 1;
                        }
                    }
                });
                if(a === 0) {
                    layer.open({
                        type:2,
                        content:url,
                        area: ['65%', '95%'],
                        end:function(){
                            location.reload();
                        }
                    });
                }
                return false;
            });

            $('.showprice').click(function(){
                var url = $(this).attr('href');
                var name = $(this).attr('data');
                layer.open({
                    title:name,
                    type:2,
                    content:url,
                    area: ['65%', '95%']
                });
                return false;
            });
            //提醒配置
            $('.notice').click(function(){
                var url = $(this).attr('href');
                layer.open({
                    title:'viator商品提醒配置信息',
                    type:2,
                    content:url,
                    area: ['80%', '95%']
                });
                return false;
            });

            $('.preview').click(function(){
                var url = $(this).attr('href');
                layer.open({
                    type:2,
                    content:url,
                    area: ['550px', '400px']
                });
                return false;
            });

            $('.changeFlag').click(function(){
                var url = $(this).attr('href');
                $.ajax({
                    url:url
                    ,async:false
                    ,success:function(res){
                        layer.msg(res.msg);
                        setTimeout(function(){
                            location.reload();
                        },1500);
                    }
                });
                return false;
            });

            //重置
            $('.clear_form').click(function(){
                $(':input','#form1')
                    .not(':button,:submit,:reset')   //将myform表单中input元素type为button、submit、reset、hidden排除
                    .val('')  //将input元素的value设为空值
                    .removeAttr('checked');
                return false;
            })

            $('.batchViatorImages').click(function () {
                var url = $(this).attr('href');
                layer.open({
                    type:2,
                    title:"批量拉取viator产品图片",
                    area:['80%','80%'],
                    content:url,
                    shadeClose:true,
                    done:function () {

                    }
                });
                return false;
            })
        });
    </script>
</body>
</html>
